<?php
abstract class  AbstractStratosphereMySQL{
	protected $db_link_mysql=false;
	protected $db_link_mysqli=false;
	function __construct($options=null) {}
	function __construct($options=null) {
		/*从环境变量里取出数据库连接需要的参数*/
		$this->host = SAE_MYSQL_HOST_M;
		$this->port = SAE_MYSQL_PORT;
		$this->user = SAE_MYSQL_USER;
		$this->pwd  = SAE_MYSQL_PASS;
		$this->dbname = SAE_MYSQL_DB;
	}
	function __destruct() {
		if($db_link_mysql){
			$this->db_link_mysql->close();
			unset( $this->db_link_mysql);
		}
		if($db_link_mysqli){
			$this->db_link_mysqli->close();
			unset( $this->db_link_mysqli);
		}
	}

	//abstract protected function getMySQL(); // 返回mysql 的 $db_link
	public function getMySQL(){
		if(!$db_link_mysql){
			$db_link_mysql=mysql_connect($this->host.':'.$this->port,$this->user,$this->pwd);
			mysql_select_db($this->dbname,$db_link_mysql);
		}
		return $db_link_mysql ;
	}
	//abstract protected function getMySQLi();// 返回mysqli的 $db_link
	public function getMySQLi(){
		if(!$db_link_mysqli){
			$db_link_mysqli = new mysqli($this->host,$this->user,$this->pwd,$this->dbname,$this->port);
		}
		return $db_link_mysqli ;
	}
}
?>